package org.lvhengchang.schoolmanager.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lvhengchang.schoolmanager.bean.Student;
import org.lvhengchang.schoolmanager.service.StudentService;
import org.lvhengchang.schoolmanager.service.impl.StudentServiceImpl;

/**
 * 学生查询处理类
 * 
 * @author LvHengchang
 *
 */
@WebServlet("/student/list")
public class StudentFindAllServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private StudentService studentService = new StudentServiceImpl();

	public StudentFindAllServlet() {
		super();
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			List<Student> students = studentService.selectByAll();
			req.setAttribute("students", students);
			req.getRequestDispatcher("/student/studentList.jsp").forward(req, resp);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
